﻿using System;
using System.Linq;
using System.Linq.Expressions;

namespace EntModApp.EntServices.Data
{
  public interface IQueryableRepository<TEntity>
    : IUnitOfWork
    where TEntity : class
  {
    IQueryable<TEntity> All();
    IQueryable<TEntity> All(out int total, int index = 0, int size = 10);

    IQueryable<TEntity> Filter(Expression<Func<TEntity, bool>> predicate);
    IQueryable<TEntity> Filter(out int total, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> sortingSelector = null, Expression<Func<TEntity, bool>> filter = null, int index = 0, int size = 10);

    TEntity Find(Expression<Func<TEntity, bool>> predicate);

    bool Contains(Expression<Func<TEntity, bool>> predicate);
    int Count();
    int Count(Expression<Func<TEntity, bool>> predicate);

    TEntity Create(TEntity entity);
    void Delete(TEntity entity);
    int Delete(Expression<Func<TEntity, bool>> predicate);
    TEntity Update(TEntity entity);
  }
}
